import component from 'element-plus/es/components/tree-select/src/tree-select-option.mjs';
import socket from '../utils/socket'
import { defineAsyncComponent } from 'vue';
export const constantRoute = [
    {
        path: '/',
        redirect: '/home',
    },
    { 
        path: '/home',
        component: () => import('../components/head/index.vue'),
        name: 'home',
        redirect:'/home/main',
        children:[
            {
                path:'/home/main',
                component:()=>import('../views/main/index.vue'),
                name:'main'
            },
            {
                path:'/home/myConf',
                component:()=>import('../views/myConf/index.vue'),
                name:'myConf',
                redirect:'/home/myConf/mine',
                children:[
                    {
                        path:'/home/myConf/mine',
                        component:()=>import('../views/myConf/mine/index.vue'),
                        name:'mine'
                    },
                    {
                        path:'/home/myConf/list',
                        component:()=>import('../views/myConf/list/index.vue'),
                        name:'list',
                          
                    },
                    {
                        path:'/home/myConf/list/create',
                        component:()=>import('../views/myConf/list/create/index.vue'),
                        name:'create'

                    },
                    {
                        path:'/home/myConf/list/create',
                        component:()=>import('../views/myConf/list/create/index.vue'),
                        name:'create'

                    },
                    {
                        path:'/home/myConf/list/detail',
                        component:()=>import('../views/myConf/list/detail/index.vue'),
                        name:'detail'

                    },
                    {
                        path:'/home/myConf/files',
                        component:()=>import('../views/myConf/files/index.vue'),
                        name:'files'
                    },
                    {
                        path:'/home/myConf/files/fielList',
                        component:()=>import('../views/myConf/files/filesList/index.vue'),
                        name:'fileList'
                    },
                    {
                        path:'/home/myConf/video',
                        component:()=>import('../views/myConf/video/index.vue'),
                        name:'video'
                    },
                    {
                        path:'/home/myConf/asistant',
                        component:()=>import('../views/myConf/asistant/index.vue'),
                        name:'asistant',
                        children:[
                            {
                                path:':id',
                                component:defineAsyncComponent(
                                    ()=>import('../components/Chat/ChatContent.vue')
                                )
                            },
                            {
                                path:'',
                                redirect: '/home/myConf/asistant/1',
                            }

                        ]
                    },
                    {
                        path:'/home/myConf/list/join',
                        component:()=>import('../views/myConf/list/join/index.vue'),
                        name:'join'
                    },
                    
                    
                ]
            }
        ]
    },
    {
        path:'/login',
        component:()=>import('../views/login/index.vue'),
        name:'login',//命名路由
 
    },
    {
        path:'/meeting',
        component:()=>import('../views/meeting/index.vue'),
        name:'meeting',
        //@ts-ignore
        beforeEnter: async(to, from) => {
            try{
                await socket.open()
                return true
            }catch(e){
                console.error(e)
            }
            
        }
    },
 
    
    {   
        path: '/:catchAll(.*)*',
        redirect: '/404',
    },
    {   
        path: '/404',
        component:()=>import('../views/404/index.vue'),
        name:'404'
    },
];
 